.class Lcom/waiqin365/base/print/e;
.super Ljava/lang/Thread;


# instance fields
.field final synthetic a:Lcom/waiqin365/base/print/b;

.field private final b:Landroid/bluetooth/BluetoothSocket;

.field private final c:Ljava/io/InputStream;

.field private final d:Ljava/io/OutputStream;


# direct methods
.method public constructor <init>(Lcom/waiqin365/base/print/b;Landroid/bluetooth/BluetoothSocket;)V
    .locals 5

    const/4 v0, 0x0

    iput-object p1, p0, Lcom/waiqin365/base/print/e;->a:Lcom/waiqin365/base/print/b;

    invoke-direct {p0}, Ljava/lang/Thread;-><init>()V

    const-string/jumbo v1, "BluetoothService"

    const-string/jumbo v2, "create ConnectedThread"

    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    iput-object p2, p0, Lcom/waiqin365/base/print/e;->b:Landroid/bluetooth/BluetoothSocket;

    :try_start_0
    invoke-virtual {p2}, Landroid/bluetooth/BluetoothSocket;->getInputStream()Ljava/io/InputStream;
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v1

    :try_start_1
    invoke-virtual {p2}, Landroid/bluetooth/BluetoothSocket;->getOutputStream()Ljava/io/OutputStream;
    :try_end_1
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_1

    move-result-object v0

    :goto_0
    iput-object v1, p0, Lcom/waiqin365/base/print/e;->c:Ljava/io/InputStream;

    iput-object v0, p0, Lcom/waiqin365/base/print/e;->d:Ljava/io/OutputStream;

    return-void

    :catch_0
    move-exception v1

    move-object v2, v1

    move-object v1, v0

    :goto_1
    const-string/jumbo v3, "BluetoothService"

    const-string/jumbo v4, "temp sockets not created"

    invoke-static {v3, v4, v2}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_0

    :catch_1
    move-exception v2

    goto :goto_1
.end method


# virtual methods
.method public a([B)V
    .locals 5

    const/4 v4, -0x1

    :try_start_0
    iget-object v0, p0, Lcom/waiqin365/base/print/e;->d:Ljava/io/OutputStream;

    invoke-virtual {v0, p1}, Ljava/io/OutputStream;->write([B)V

    iget-object v0, p0, Lcom/waiqin365/base/print/e;->a:Lcom/waiqin365/base/print/b;

    invoke-static {v0}, Lcom/waiqin365/base/print/b;->d(Lcom/waiqin365/base/print/b;)Landroid/os/Handler;

    move-result-object v0

    const/4 v1, 0x3

    const/4 v2, -0x1

    const/4 v3, -0x1

    invoke-virtual {v0, v1, v2, v3, p1}, Landroid/os/Handler;->obtainMessage(IIILjava/lang/Object;)Landroid/os/Message;

    move-result-object v0

    invoke-virtual {v0}, Landroid/os/Message;->sendToTarget()V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    :goto_0
    return-void

    :catch_0
    move-exception v0

    iget-object v1, p0, Lcom/waiqin365/base/print/e;->a:Lcom/waiqin365/base/print/b;

    invoke-static {v1}, Lcom/waiqin365/base/print/b;->d(Lcom/waiqin365/base/print/b;)Landroid/os/Handler;

    move-result-object v1

    const/16 v2, 0x8

    invoke-virtual {v1, v2, v4, v4, p1}, Landroid/os/Handler;->obtainMessage(IIILjava/lang/Object;)Landroid/os/Message;

    move-result-object v1

    invoke-virtual {v1}, Landroid/os/Message;->sendToTarget()V

    const-string/jumbo v1, "BluetoothService"

    const-string/jumbo v2, "Exception during write"

    invoke-static {v1, v2, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_0
.end method

.method public cancel()V
    .locals 3

    :try_start_0
    iget-object v0, p0, Lcom/waiqin365/base/print/e;->b:Landroid/bluetooth/BluetoothSocket;

    invoke-virtual {v0}, Landroid/bluetooth/BluetoothSocket;->close()V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    :goto_0
    return-void

    :catch_0
    move-exception v0

    const-string/jumbo v1, "BluetoothService"

    const-string/jumbo v2, "close() of connect socket failed"

    invoke-static {v1, v2, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_0
.end method

.method public run()V
    .locals 5

    const-string/jumbo v0, "ConnectedThread\u7ebf\u7a0b\u8fd0\u884c"

    const-string/jumbo v1, "\u6b63\u5728\u8fd0\u884c......"

    invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    const-string/jumbo v0, "BluetoothService"

    const-string/jumbo v1, "BEGIN mConnectedThread"

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    :goto_0
    const/16 v0, 0x100

    :try_start_0
    new-array v0, v0, [B

    iget-object v1, p0, Lcom/waiqin365/base/print/e;->c:Ljava/io/InputStream;

    invoke-virtual {v1, v0}, Ljava/io/InputStream;->read([B)I

    move-result v1

    if-gtz v1, :cond_1

    const-string/jumbo v0, "BluetoothService"

    const-string/jumbo v1, "disconnected"

    invoke-static {v0, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    iget-object v0, p0, Lcom/waiqin365/base/print/e;->a:Lcom/waiqin365/base/print/b;

    invoke-static {v0}, Lcom/waiqin365/base/print/b;->e(Lcom/waiqin365/base/print/b;)V

    iget-object v0, p0, Lcom/waiqin365/base/print/e;->a:Lcom/waiqin365/base/print/b;

    invoke-static {v0}, Lcom/waiqin365/base/print/b;->b(Lcom/waiqin365/base/print/b;)I

    move-result v0

    if-eqz v0, :cond_0

    const-string/jumbo v0, "BluetoothService"

    const-string/jumbo v1, "disconnected"

    invoke-static {v0, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    iget-object v0, p0, Lcom/waiqin365/base/print/e;->a:Lcom/waiqin365/base/print/b;

    invoke-virtual {v0}, Lcom/waiqin365/base/print/b;->h()V

    :cond_0
    :goto_1
    return-void

    :cond_1
    iget-object v2, p0, Lcom/waiqin365/base/print/e;->a:Lcom/waiqin365/base/print/b;

    invoke-static {v2}, Lcom/waiqin365/base/print/b;->d(Lcom/waiqin365/base/print/b;)Landroid/os/Handler;

    move-result-object v2

    const/4 v3, 0x2

    const/4 v4, -0x1

    invoke-virtual {v2, v3, v1, v4, v0}, Landroid/os/Handler;->obtainMessage(IIILjava/lang/Object;)Landroid/os/Message;

    move-result-object v0

    invoke-virtual {v0}, Landroid/os/Message;->sendToTarget()V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    move-exception v0

    const-string/jumbo v1, "BluetoothService"

    const-string/jumbo v2, "disconnected"

    invoke-static {v1, v2, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    iget-object v0, p0, Lcom/waiqin365/base/print/e;->a:Lcom/waiqin365/base/print/b;

    invoke-static {v0}, Lcom/waiqin365/base/print/b;->e(Lcom/waiqin365/base/print/b;)V

    iget-object v0, p0, Lcom/waiqin365/base/print/e;->a:Lcom/waiqin365/base/print/b;

    invoke-static {v0}, Lcom/waiqin365/base/print/b;->b(Lcom/waiqin365/base/print/b;)I

    move-result v0

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/waiqin365/base/print/e;->a:Lcom/waiqin365/base/print/b;

    invoke-virtual {v0}, Lcom/waiqin365/base/print/b;->h()V

    goto :goto_1
.end method
